package com.my.chapter11;

import java.util.ArrayList;
import java.util.Iterator;

public class practice8 {
    public static void main(String[] args) {
        ArrayList<Gerbil8> al = new ArrayList<Gerbil8>();
        for(int i=0;i<7;i++){
            al.add(new Gerbil8(i));
        }
        Gerbil8.hop(al.iterator());
    }
}

class Gerbil8{
    int gerbilNumber;
    public Gerbil8(int gerbilNumber){
        this.gerbilNumber = gerbilNumber;
    }

    static void hop(Iterator<Gerbil8> it){
        while(it.hasNext()){
            int num = it.next().gerbilNumber;
            System.out.println("Gerbil" + num + "is hoping");
        }
    }
}
